﻿function Get-TSMPolicySet {    
    <#
        .SYNOPSIS
            Get TSM policy sets
                    
        .DESCRIPTION
            The Get-TSMPolicySet returns policy sets

        .PARAMETER Domain
            Domain to search

        .PARAMETER PolicySet
            Policy set to search

        .EXAMPLE
            Get-TSMPolicySet

        .NOTES
            Contributors:  David Seibel
            Last Revision Date: 09/01/2015

    #>
    [CmdletBinding()]
    Param(
        [Parameter(Position = 0)]
        $Domain,

        [Parameter(Position = 1)]
        $PolicySet
    )
    
    $whereProps = @()
    $whereProps += [PSCustomObject]@{ "Column" = "DOMAIN_NAME"; "Operator" = "LIKE"; "Value" = $Domain }
    $whereProps += [PSCustomObject]@{ "Column" = "SET_NAME";    "Operator" = "LIKE"; "Value" = $PolicySet }

    $query = Format-TSMQuery -Table "POLICYSETS" -Where $whereProps -OrderBy "DOMAIN_NAME,SET_NAME"
    $result = Invoke-TSMCommand -Command $query

    $defaultDisplaySet = 'DOMAIN_NAME','SET_NAME','DEFMGMTCLASS','DESCRIPTION'
    $typeDefinitions = @{
                        "CHG_TIME" = [DateTime]
                        }

    return Format-TSMData -Data $result -TypeDefinitions $typeDefinitions -DefaultDisplaySet $defaultDisplaySet
}